﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace SpringBeansEditor.Commands
{
    public class RemoveObjectCommand: IXmlCommand
    {

        public delegate void ExecutedDelegate(IXmlCommand cmd);
        public ExecutedDelegate OnExecute { get; set; }

        public bool IsAllowedInNode(XmlNode curr_xml_node)
        {
            return (curr_xml_node.Name.ToLowerInvariant() == "object");
        }

        public string GetLabel()
        {
            return "Remove Object";
        }

        public void Execute(XmlDocument xml_data, XmlNode curr_xml_node)
        {
            XmlNode parent = curr_xml_node.ParentNode;
            parent.RemoveChild(curr_xml_node);
            OnExecute(this);
        }
    
    }
}
